#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include "book.h"
#include <stdlib.h>

bool FindList(P_Node_t p)
{
    if (p == NULL|| p->next == NULL)
    {
        printf("书籍信息库为空！\n");
        return false;
    }
    char arr[20] = {0};
    printf("请输入您要查找书籍的书名，作者或JSBN：");
    scanf("%s", arr);
    P_Node_t q = p->next;
    while (q != NULL)
    {
        if (strcmp(arr, q->data.name) == 0 || strcmp(arr, q->data.Author) == 0 
            || strcmp(arr, q->data.JSBN) == 0)
        {
            printf("===============================\n");
            printf("书名：%s\n", q->data.name);
            printf("作者：%s\n", q->data.Author);
            printf("JSBN：%s\n", q->data.JSBN);
            printf("出版社：%s\n", q->data.Publisher);
            printf("出版年份：%d\n", q->data.year);
            printf("库存数量：%d\n", q->data.num);
            printf("当前借出数量：%d\n", q->data.count);
            printf("===============================\n");
            return true;
        }
        q = q->next;
    }
    printf("没有找到您所查找书籍的信息！\n");
    return false;
    
}